﻿using SuperMap.Realspace;
using SuperMap.UI;
using System;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using Ycjw.PipeLine.Map.Basic.Conditions;

namespace Ycjw.PipeLine.Map.Basic
{
    /****************************************************************************************/
    /*
    功    能:放置三维场景的DocWindow
    作    者: RenZachary
    联系方式: rzcgis@foxmail.com（QQ455745253）
    生成日期: 2021年3月24日
    修改日志: 
    版权说明: @2021 西安云创经纬信息科技有限公司 版权所有 All right reserved.
    注    意: 本内容仅限于云创经纬公司内部使用，禁止用于商业目的。
    */
    /****************************************************************************************/
    public class SceneEx : DocWindowExtend
    {
        private SceneControl m_SceneControl;
        DockPanel m_DockPanel;
        public Scene Scene
        {
            get
            {
                return m_SceneControl.Scene;
            }
        }

        public SceneControl SceneControl { get => m_SceneControl; set => m_SceneControl = value; }

        public SceneEx()
        {
            this.TabText = "三维场景";
        }
        public void SetDockPanel(DockPanel dp)
        {
            m_DockPanel = dp;
        }
        protected override void OnLoad(EventArgs e)
        {
            AddSceneControl();
        }
        public void RemoveAllToolBar()
        {
            foreach (Control control in Controls)
            {
                if (control is BasicToolBar)
                {
                    (control as BasicToolBar).AfterClose();
                    this.Controls.Remove(control);
                    break;
                }
            }
        }
        public void AddToolBar(BasicToolBar basicToolBar)
        {
            RemoveAllToolBar();
            basicToolBar.Dock = DockStyle.Top;
            this.Controls.Add(basicToolBar);
        }
        void AddSceneControl()
        {
            if (m_SceneControl != null) return;
            m_SceneControl = new SceneControl
            {
                Dock = DockStyle.Fill
            };
            this.Controls.Add(m_SceneControl);
            LoadLayer3DsTree(m_DockPanel);
        }

        void LoadLayer3DsTree(DockPanel dp)
        {
            LayersTreeEx lyrTree = new LayersTreeEx(this.Scene);
            lyrTree.Show(dp,DockState.DockLeft);
        }
    }
}
